home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- *
- * WAXString
- *
- * A wrapper for ActiveX strings (BSTRs) that combines the
- * features of WString with those of WBString.
- *
- * Copyright 1998 by Sybase, Inc. All rights reserved.
- *
- *******************************************************************/
-
- #ifndef _WAXSTRING_HPP_INCLUDED
- #define _WAXSTRING_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WSTRING_HPP_INCLUDED
- #include "wstring.hpp"
- #endif
-
- #ifndef _WOLEBSTR_HPP_INCLUDED
- #include "wolebstr.hpp"
- #endif
-
-
- //
- // WAXString
- //
-
- class WCMCLASS WAXString : public WString {
- WDeclareSubclass( WAXString, WString )
-
- public:
- WAXString();
- WAXString( const WString & str );
- WAXString( const WBString & str );
- WAXString( const WChar *str, WULong numChars=USE_STR_LEN );
- WAXString( WBStr handle, WBool copyHandle,
- WBool deleteHandle=TRUE );
- WAXString( const WResourceID & id, WModuleHandle modHandle=_ApplicationModule );
- WAXString( const WMessageID & id, WModuleHandle modHandle=_ApplicationModule );
-
- ~WAXString();
-
- // Casting operators
-
- operator const WBStr() const { return GetHandle(); }
- operator const WAnsiChar*() const { return GetAnsiText(); }
- operator const WBString() const { return WBString( *this ); }
-
- // = operator
-
- WAXString & operator=( const WAnsiChar *s );
- WAXString & operator=( const WUnicodeChar *s );
- WAXString & operator=( const WString & s );
- WAXString & operator=( const WBString & s );
-
- // += operator
-
- WAXString & operator+=( const WAnsiChar *s );
- WAXString & operator+=( const WUnicodeChar *s );
- WAXString & operator+=( const WString & s );
- WAXString & operator+=( const WBString & s );
- WAXString & operator+=( WAnsiChar a );
- WAXString & operator+=( WUnicodeChar u );
-
- // + operator
-
- WAXString operator+( const WAnsiChar *s );
- WAXString operator+( const WUnicodeChar *s );
- WAXString operator+( const WString & s );
- WAXString operator+( const WBString & s );
- WAXString operator+( WAnsiChar a );
- WAXString operator+( WUnicodeChar u );
- friend WAXString WEXPORT operator+( const WAnsiChar *a, const WAXString & b );
- friend WAXString WEXPORT operator+( const WUnicodeChar *a, const WAXString & b );
-
- // Copy
- //
- // Copies an arbitrary BSTR.
-
- static WBStr Copy( WBStr handle );
-
- // Create
- //
- // Create a WAXString from various sources.
-
- WBool Create();
- WBool Create( const WString & str );
- WBool Create( const WBString & str );
- WBool Create( const WChar *str, WULong numChars=USE_STR_LEN );
- WBool Create( WBStr handle, WBool copyHandle,
- WBool deleteHandle=TRUE );
- WBool Create( const WResourceID & id, WModuleHandle modHandle=_ApplicationModule );
- WBool Create( const WMessageID & id, WModuleHandle modHandle=_ApplicationModule );
-
- // Free
- //
- // Frees an arbitrary BSTR.
-
- static void Free( WBStr handle );
-
- // Handle
- //
- // Set or get as a BSTR.
-
- WBStr GetHandle( WBool copyHandle=FALSE ) const;
- WBool SetHandle( WBStr handle, WBool copyHandle=FALSE,
- WBool deleteHandle=TRUE );
-
- // Left
- //
- // Return the n leftmost characters.
-
- WAXString Left( WULong numChars ) const;
-
- // Right
- //
- // Return the n rightmost characters.
-
- WAXString Right( WULong numChars ) const;
-
- // SetDirty
- //
- // Called whenever someone has
- // changed the WString. We can use this
- // notification to reset our internal string data.
-
- virtual WBool SetDirty( WBool dirty=TRUE );
-
- // Strip
- //
- // Return the string trimmed of whitespace.
-
- WAXString Strip( WBool fromBeg=TRUE, WBool fromEnd=TRUE ) const;
-
- // Substring
- //
- // Return a substring.
-
- WAXString Substring( WULong startAt, WULong numChars=USE_STR_LEN ) const;
-
-
-
- protected:
- virtual WBool PrepareForRead() const;
-
- WBStr _handle;
- WBool _deleteHandle;
- };
-
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WAXSTRING_HPP_INCLUDED
-